from abc import ABC, abstractmethod

__all__ = ["Marshaler"]


class Marshaler[T](ABC):
    """
    A marshaler.

    A marshaler is an object that can marshal a stage into file(s). This is used for outputting data to a file in
    this project.
    """

    @abstractmethod
    def marshal(self, stage: T) -> None:
        """
        Marshal a stage.

        This method does not take any arguments. Any possible arguments should be passed in the constructor of the
        marshaler (e.g. a file path).

        Args:
            stage: The stage to marshal.
        """
        raise NotImplementedError()

    def __call__(self, stage: T) -> None:
        return self.marshal(stage)
